package sample.plugin.html.project;

import android.graphics.drawable.Drawable;

import com.rapid.api.ext.plugin.AndroidPlugins;
import com.rapid.api.framework.project.file.DefaultOpeningOption;
import com.rapid.api.project.CodeProjectManager;
import com.rapid.api.project.TypeDescription;
import com.rapid.util.android.ContextUtils;

import java.io.File;

import sample.plugin.html.R;
import sample.plugin.html.lang.HtmlLanguage;
import sample.plugin.html.lang.operator.HtmlOperatorProvider;
import sample.plugin.html.project.template.HtmlDefaultTemplate;

/**
 * Html项目管理器类
 */
public class HtmlProjectManager extends CodeProjectManager<HtmlProject> {
    public final static String TYPE = "Html工程";
    public final static String IDENTIFIER = "sample.html";

    public HtmlProjectManager() {
        super();
        this.fileManager = new HtmlFileManager();
        fileManager.enableProjectJSONFilter();
        fileManager.addPSObjectOpeningOption(DefaultOpeningOption.INSTANCE, ".html", ".js", ".css", ".htm");
        languageManager.registerOperatorProvider(HtmlLanguage.ID, new HtmlOperatorProvider());
        addTemplate(new HtmlDefaultTemplate());
    }

    @Override
    public String getIdentifier() {
        return IDENTIFIER;
    }

    @Override
    public TypeDescription getTypeDescription() {
        Drawable drawable = ContextUtils.getDrawable(
                AndroidPlugins.getContext(this),
                R.drawable.ic_project_html
        );
        return new TypeDescription(TYPE, TypeDescription.APPLICATION, drawable);
    }

    @Override
    public HtmlProject newProject() {
        return new HtmlProject();
    }

    @Override
    public boolean isProjectDir(File file) {
        return false;
    }
}
